<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>养老金/提前退休提取金额测算系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
            padding: 30px;
        }

        h1 {
            color: #2c3e50;
            margin-bottom: 10px;
            text-align: center;
        }

        .subtitle {
            color: #7f8c8d;
            text-align: center;
            margin-bottom: 30px;
            font-size: 14px;
        }

        .form-section {
            background: #f8f9fa;
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 30px;
        }

        .form-section h2 {
            color: #495057;
            margin-bottom: 20px;
            font-size: 18px;
        }

        .form-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .form-group {
            display: flex;
            flex-direction: column;
        }

        .form-group label {
            margin-bottom: 8px;
            color: #495057;
            font-weight: 500;
            font-size: 14px;
        }

        .form-group input,
        .form-group select {
            padding: 10px;
            border: 1px solid #dee2e6;
            border-radius: 6px;
            font-size: 14px;
            transition: border-color 0.3s;
        }

        .form-group input:focus,
        .form-group select:focus {
            outline: none;
            border-color: #667eea;
        }

        .btn {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            padding: 12px 30px;
            border-radius: 6px;
            font-size: 16px;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
            display: block;
            margin: 20px auto;
        }

        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }

        .btn:active {
            transform: translateY(0);
        }

        .table-container {
            overflow-x: auto;
            margin-top: 30px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            background: white;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        thead {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        th {
            padding: 12px;
            text-align: left;
            font-weight: 600;
            font-size: 14px;
        }

        td {
            padding: 12px;
            border-bottom: 1px solid #e9ecef;
            font-size: 14px;
        }

        tbody tr:hover {
            background: #f8f9fa;
        }

        tbody tr:nth-child(even) {
            background: #f8f9fa;
        }

        .editable {
            background: #fff3cd;
            border: 1px solid #ffc107;
            border-radius: 4px;
            padding: 6px;
            width: 100%;
            font-size: 14px;
        }

        .editable:focus {
            outline: none;
            border-color: #667eea;
            background: white;
        }

        .readonly {
            background: #e9ecef;
            color: #495057;
            font-weight: 500;
        }

        .positive {
            color: #28a745;
            font-weight: 600;
        }

        .negative {
            color: #dc3545;
            font-weight: 600;
        }

        .info-box {
            background: #d1ecf1;
            border-left: 4px solid #0c5460;
            padding: 15px;
            margin-bottom: 20px;
            border-radius: 4px;
        }

        .info-box p {
            margin: 5px 0;
            color: #0c5460;
            font-size: 14px;
        }

        .summary {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin-bottom: 30px;
        }

        .summary-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 8px;
            text-align: center;
        }

        .summary-card h3 {
            font-size: 14px;
            margin-bottom: 10px;
            opacity: 0.9;
        }

        .summary-card .value {
            font-size: 24px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>养老金/提前退休提取金额测算系统</h1>
        <p class="subtitle">基于4%提取率的第一层级测算体系</p>

        <div class="info-box">
            <p><strong>说明：</strong>这个系统用于测算以现有资产为基础，在正常情况下，直到离开这个世界那一天，每年可以花多少钱。</p>
            <p>第一层级：4%提取率。这是整个测算体系的基础。</p>
            <p>流动资产包括：现金、股票、债券、黄金等可以轻易变现的资产。房产等固定资产不计入。</p>
        </div>

        <div class="form-section">
            <h2>基础设置</h2>
            <div class="form-row">
                <div class="form-group">
                    <label for="initialYear">起始年份</label>
                    <input type="number" id="initialYear" value="2026" min="2020" max="2050">
                </div>
                <div class="form-group">
                    <label for="initialValue">初始资产（年初价值）</label>
                    <input type="number" id="initialValue" value="1000000" step="10000" min="0">
                </div>
                <div class="form-group">
                    <label for="withdrawalRate">提款率 (%)</label>
                    <input type="number" id="withdrawalRate" value="4" step="0.1" min="0" max="10">
                </div>
                <div class="form-group">
                    <label for="defaultReturnRate">默认年化收益率 (%)</label>
                    <input type="number" id="defaultReturnRate" value="5" step="0.5" min="-20" max="30">
                </div>
                <div class="form-group">
                    <label for="yearsCount">测算年数</label>
                    <input type="number" id="yearsCount" value="30" step="1" min="10" max="50">
                </div>
            </div>
            <div style="display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;">
                <button class="btn" onclick="generateTable()">生成测算表</button>
                <button class="btn" onclick="generateRandomReturns()" style="background: linear-gradient(135deg, #28a745 0%, #20c997 100%);">生成随机收益率</button>
            </div>
        </div>

        <div class="summary" id="summarySection" style="display: none;">
            <div class="summary-card">
                <h3>当前年初价值</h3>
                <div class="value" id="currentValue">¥0</div>
            </div>
            <div class="summary-card">
                <h3>今年可提取金额</h3>
                <div class="value" id="currentWithdrawal">¥0</div>
            </div>
            <div class="summary-card">
                <h3>提款后价值</h3>
                <div class="value" id="afterWithdrawal">¥0</div>
            </div>
        </div>

        <div class="table-container">
            <table id="calculationTable" style="display: none;">
                <thead>
                    <tr>
                        <th>年份</th>
                        <th>年初价值</th>
                        <th>上年回报率 (%)</th>
                        <th>提款率 (%)</th>
                        <th>基础提款</th>
                        <th>提款后价值</th>
                    </tr>
                </thead>
                <tbody id="tableBody">
                    <!-- 表格数据将在这里动态生成 -->
                </tbody>
            </table>
        </div>
    </div>

    <script src="retirement-calculator.js"></script>
</body>
</html>

